}
if (strncmp(ibuf, "$PMGNTRK,", 7) == 0) {
waypoint *wpt = mag_trkparse(ibuf);
+ /*
+ * Allow lazy allocation of track head.
+ */
+ if (trk_head == NULL) {
+ trk_head = route_head_alloc();
+ track_add_head(trk_head);
+ }
+
route_add_wpt(trk_head, wpt);
}
if (strncmp(ibuf, "$PMGNRTE,", 7) == 0) {
switch (global_opts.objective)
{
case trkdata:
- trk_head = route_head_alloc();
- track_add_head(trk_head);
-
if (!is_file)
mag_writemsg("PMGNCMD,TRACK,2");